<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/include/tagLib.jsp" %>
<!doctype html>
<html lang="en">
<head>
    <title>${sieName}-系统设置</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <%@include file="/include/cssLib.jsp" %>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- 菜单 -->
            <tag:nav key="sysAdmin"/>

            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="card col-md-10 col-md-offset-1">
                        <tag:sys-nav key="adminConsole"/>
                        <div class="card-content">
                            <div class="tab-content">
                                <div class="tab-pane active" >
                                    <div class="row hide">
                                        <div class="card-content">
                                            <div class="col-md-4 bd-grey">
                                                <div class="card-header">
                                                    <h4 class="card-title">配置第三方自然语言能力</h4>
                                                </div>
                                                <div class="card-content">
                                                    <div class="row">
                                                        <div class="col-sm-2 form-group text-right">
                                                            <label class="label-on-left">百度云：</label>
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretId" type="email" placeholder="SecretId" />
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretKey" type="email" placeholder="SecretKey"/>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-2 form-group text-right">
                                                            <label class="label-on-left">腾讯云：</label>
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretId" type="email" placeholder="SecretId" />
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretKey" type="email" placeholder="SecretKey"/>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-2 form-group text-right">
                                                            <label class="label-on-left">玻森：</label>
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretId" type="email" placeholder="SecretId" />
                                                        </div>
                                                        <div class="col-sm-4 form-group label-floating">
                                                            <input class="form-control" name="SecretKey" type="email" placeholder="SecretKey"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group label-floating">
                                                        <button type="button"  class="btn btn-rose btn-sm">更新</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="card-content">
                                            <%-- <div class="col-md-3 bd-grey">
                                                 <div class="card-header">
                                                     <h4 class="card-title">设置管理员邮箱</h4>
                                                 </div>
                                                 <div class="card-content">
                                                     <div class="form-group label-floating">
                                                         <input class="form-control" id="adminMail" type="email" value="${fns:getOneDictValueByType('admin_mail')}" placeholder="填写管理员邮箱" />
                                                     </div>
                                                     <div class="form-group label-floating">
                                                         <button type="button" onclick="updateAdminMail()" class="btn btn-rose btn-sm">更新</button>
                                                     </div>
                                                 </div>
                                             </div>
                                             --%>
                                            <div class="col-md-7 bd-grey">
                                                <div class="card-header">
                                                    <h4 class="card-title">设置钉钉群通知<small class="mgl-10"><a href="https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.Hd3OF7&treeId=385&articleId=104980&docType=1" target="_blank">官方文档</a></small></h4>
                                                </div>
                                                <div class="card-content form-horizontal">

                                                    <div class="row">
                                                        <label class="col-sm-3 label-on-left">运维群（chatId）：</label>
                                                        <div class="col-sm-8">
                                                            <div class="row">
                                                                <div class="col-md-8">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <input class="form-control" value="${fns:getOneDictValueByType('ding_ops_group')}" id="opsChatId" type="text"/>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <button type="button" class="btn btn-rose btn-sm" onclick="updateDingTalkGroup('ding_ops_group', 'opsChatId')">更新</button>
                                                                        <small class="mgl-10"><a href="https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.7jEnLX&treeId=385&articleId=104977&docType=1#s1" target="_blank">文档</a></small>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="row">
                                                        <label class="col-sm-3 label-on-left">运维群消息：</label>
                                                        <div class="col-sm-8">
                                                            <div class="row">
                                                                <div class="col-md-8">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <input class="form-control" id="opsChatMsg" type="text"/>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <button type="button" class="btn btn-success btn-sm" onclick="sendDingTalkMsg('ding_ops_group', 'opsChatMsg')">测试</button>
                                                                        <small class="mgl-10"><a href="https://wx.dingtalk.com/invite-page/weixin.html?code=39c4aa933c&inviterUid=280D85E51ED9FDA2C037C4C722B98659&deptId=-1" target="_blank">加群</a></small>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <hr>

                                                    <div class="row">
                                                        <label class="col-sm-3 label-on-left">管理员群（chatId）：</label>
                                                        <div class="col-sm-8">
                                                            <div class="row">
                                                                <div class="col-md-8">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <input class="form-control" value="${fns:getOneDictValueByType('ding_admin_group')}" id="adminChatId" type="text"/>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <button type="button" class="btn btn-rose btn-sm" onclick="updateDingTalkGroup('ding_admin_group', 'adminChatId')">更新</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="row">
                                                        <label class="col-sm-3 label-on-left">管理员群消息：</label>
                                                        <div class="col-sm-8">
                                                            <div class="row">
                                                                <div class="col-md-8">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <input class="form-control" id="adminChatMsg" type="text"/>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4">
                                                                    <div class="form-group label-floating is-empty">
                                                                        <button type="button" class="btn btn-success btn-sm" onclick="sendDingTalkMsg('ding_admin_group', 'adminChatMsg')">测试</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="/include/sidebarRight.jsp" %>
</body>
<%@include file="/include/scriptLib.jsp" %>

<script type="text/javascript">
    $(document).ready(function() {

    });

    function updateAdminMail(){
        var adminMail = $("#adminMail").val();
        if(CommUtil.isNotEmpty(adminMail)){
            HttpUtil.ajaxAsyncJsonPost('/adminConsole/superAdmin/setAdminMail', {adminMail: adminMail}, function(message){
                dialogRightTopTip(message);
            });
        }
    }

    function sendDingTalkMsg(type, msgInputId){
        var msg = $("#"+msgInputId).val();
        if(CommUtil.isEmpty(msg)){
            $("#"+msgInputId).focus();
            return;
        }
        HttpUtil.ajaxAsyncJsonPost('/adminConsole/superAdmin/testDingTalk', {groupType: type, message: msg}, function(message){
            dialogRightTopTip(message, 'success');
        });
    }

    function updateDingTalkGroup(type, chatInputId){
        var chatInputVal = $("#"+chatInputId).val();
        if(CommUtil.isEmpty(chatInputVal)){
            $("#"+chatInputId).focus();
            return;
        }
        HttpUtil.ajaxAsyncJsonPost('/adminConsole/superAdmin/setDingTalkGroup', {groupType: type, chatId: chatInputVal}, function(message){
            dialogRightTopTip(message, 'success');
        });
    }
</script>

</html>